package com.none.web.model;

import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.persistence.OrderBy;

/**
 * TNews entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "t_news")
public class TNews implements java.io.Serializable {
	private static final long serialVersionUID = -5355580865198461713L;

	// Fields
	/**
	 * 
	 */
	@Id
	private Integer newsId; // 新闻id
	
	private String title; // 标题
	private String briefContent; // 概要
	private String content; // 内容
	private String pic; // 图片
	private String video; // 视频
	private String videoPrevPic; // 视频
	private String type; // 类型
	private String status; // 状态

	private TUser authorUser;// 作者
	private Timestamp addTime; // 添加时间

	private TUser updateUser;// 修改人员
	private Timestamp editTime; // 修改时间

	private TUser approvalUser;// 审批人员
	private Timestamp approvalTime;// 审批时间
	
	private Timestamp toBePostedTime; //
	
	private Timestamp submit_time;//提交时间
	private String submit_user_id;//提交人Id
    private String submit_user_name;//提交人姓名
    private String pushInfo;//编辑后的推送信息

	private Set<TTags> TTagses = new HashSet<TTags>(0);
	private Set<TBeacon> TBeacons = new HashSet<TBeacon>(0);
    private String types;
	private List<TNewsImage> imageList = new ArrayList<TNewsImage>(0);//add by william 2014-12-11
	
	private Integer likeAmount ;
	private List<TComments> commentList = new ArrayList<TComments>(0);
	private Integer browseTimes;//总浏览量（同一人浏览多次算一次）
	private Integer allBrowseTimes;//总浏览量（同一人浏览几次算几次）
	private boolean isLike;
	private Integer commentAmount;
	private Integer push_count;
	private String push;
	
	private String videoFlag;//如果content中包含视频信息，设置为video,否则为notvideo
	private String haveNowTagFlag;//是否包含now标签
	// Constructors

	/** default constructor */
	public TNews() {
	}

	/** minimal constructor */
	public TNews(Integer newsId, Timestamp addTime) {
		this.newsId = newsId;
		this.addTime = addTime;
	}

	/** full constructor */
	public TNews(Integer newsId, String title, String content, String pic, String video, Timestamp addTime,
			Set<TTags> TTagses, String type, Set<TBeacon> TBeacons, String status, String briefContent,
			TUser authorUser, TUser updateUser, TUser approvalUser, Timestamp approvalTime, Timestamp editTime,Timestamp toBePostedTime) {
		this.newsId = newsId;
		this.title = title;
		this.content = content;
		this.pic = pic;
		this.video = video;
		this.addTime = addTime;
		this.TTagses = TTagses;
		this.type = type;
		this.TBeacons = TBeacons;
		this.status = status;
		this.briefContent = briefContent;
		this.updateUser = updateUser;
		this.authorUser = authorUser;
		this.editTime = editTime;
		this.approvalUser = approvalUser;
		this.approvalTime = approvalTime;
		this.toBePostedTime=toBePostedTime;
	}

	// Property accessors
	@Id
	@Column(name = "news_id", unique = true, nullable = false, length = 11)
	public Integer getNewsId() {
		return this.newsId;
	}

	public void setNewsId(Integer newsId) {
		this.newsId = newsId;
	}

	@Column(name = "title", length = 20)
	public String getTitle() {
		return this.title;
	}

	public void setTitle(String title) {
		this.title = title;
	}


	@Column(name = "brief_content", length = 1000)
	public String getBriefContent() {
		return briefContent;
	}

	public void setBriefContent(String briefContent) {
		this.briefContent = briefContent;
	}

	@Column(name = "content", length = 65535)
	public String getContent() {
		return this.content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	@Column(name = "pic", length = 50)
	public String getPic() {
		return this.pic;
	}

	public void setPic(String pic) {
		this.pic = pic;
	}

	@Column(name = "video", length = 50)
	public String getVideo() {
		return this.video;
	}

	public void setVideo(String video) {
		this.video = video;
	}
	
	@Column(name = "video_prev_pic", length = 255)
	public String getVideoPrevPic() {
		return this.videoPrevPic;
	}

	public void setVideoPrevPic(String videoPrevPic) {
		this.videoPrevPic = videoPrevPic;
	}
	

	@Column(name = "add_time", nullable = false, length = 19)
	public Timestamp getAddTime() {
		return this.addTime;
	}

	public void setAddTime(Timestamp addTime) {
		this.addTime = addTime;
	}

	@Column(name = "edit_time", nullable = false, length = 19)
	public Timestamp getEditTime() {
		return editTime;
	}

	public void setEditTime(Timestamp editTime) {
		this.editTime = editTime;
	}

	@ManyToMany(cascade = { CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH }, fetch = FetchType.LAZY)
	@OrderBy("tagId ASC")
	@JoinTable(name = "t_new_tag", joinColumns = { @JoinColumn(name = "news_id", updatable = false) }, inverseJoinColumns = { @JoinColumn(name = "tag_id", updatable = false) })
	public Set<TTags> getTTagses() {
		return this.TTagses;
	}

	public void setTTagses(Set<TTags> TTagses) {
		this.TTagses = TTagses;
	}

	@OneToMany(mappedBy = "tnews")
	public Set<TBeacon> getTBeacons() {
		return TBeacons;
	}

	public void setTBeacons(Set<TBeacon> tBeacons) {
		TBeacons = tBeacons;
	}

	@Column(name = "type", length = 50)
	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	@Column(name = "status", length = 50)
	public String getStatus() {
		return status;
	}

	public void setStatus(String status) {
		this.status = status;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "author_user_id")
	public TUser getAuthorUser() {
		return authorUser;
	}

	public void setAuthorUser(TUser authorUser) {
		this.authorUser = authorUser;
	}

	@ManyToOne( fetch = FetchType.LAZY)
	@JoinColumn(name = "update_user_id")
	public TUser getUpdateUser() {
		return updateUser;
	}

	public void setUpdateUser(TUser updateUser) {
		this.updateUser = updateUser;
	}

	@ManyToOne( fetch = FetchType.LAZY)
	@JoinColumn(name = "approval_user_id")
	public TUser getApprovalUser() {
		return approvalUser;
	}

	public void setApprovalUser(TUser approvalUser) {
		this.approvalUser = approvalUser;
	}

	@Column(name = "approval_time", nullable = false, length = 19)
	public Timestamp getApprovalTime() {
		return approvalTime;
	}

	public void setApprovalTime(Timestamp approvalTime) {
		this.approvalTime = approvalTime;
	}
	
	@Column(name = "to_bePosted_time", nullable = true, length = 19)
	public Timestamp getToBePostedTime() {
		return toBePostedTime;
	}

	public void setToBePostedTime(Timestamp toBePostedTime) {
		this.toBePostedTime = toBePostedTime;
	}

	
	@Transient
	public String getTypes() {
		return types;
	}

	public void setTypes(String types) {
		this.types = types;
	}

	@Transient
	public List<TNewsImage> getImageList() {
		return imageList;
	}

	public void setImageList(List<TNewsImage> imageList) {
		this.imageList = imageList;
	}

	@Transient
	public Integer getLikeAmount() {
		return likeAmount;
	}

	public void setLikeAmount(Integer likeAmount) {
		this.likeAmount = likeAmount;
	}
	@Transient
	public List<TComments> getCommentList() {
		return commentList;
	}

	public void setCommentList(List<TComments> commentList) {
		this.commentList = commentList;
	}
	@Transient
	public Integer getBrowseTimes() {
		return browseTimes;
	}

	public void setBrowseTimes(Integer browseTimes) {
		this.browseTimes = browseTimes;
	}
	@Transient
	public boolean isLike() {
		return isLike;
	}

	public void setLike(boolean isLike) {
		this.isLike = isLike;
	}
	@Transient
	public Integer getCommentAmount() {
		return commentAmount;
	}

	public void setCommentAmount(Integer commentAmount) {
		this.commentAmount = commentAmount;
	}
	@Transient
	public Integer getAllBrowseTimes() {
		return allBrowseTimes;
	}

	public void setAllBrowseTimes(Integer allBrowseTimes) {
		this.allBrowseTimes = allBrowseTimes;
	}

	/**
	 * @return the push_count
	 */
	@Column(name = "push_count")
	public Integer getPush_count() {
		return push_count;
	}

	/**
	 * @param push_count the push_count to set
	 */
	public void setPush_count(Integer push_count) {
		this.push_count = push_count;
	}

	/**
	 * @return the push
	 */
	@Column(name = "push")
	public String getPush() {
		return push;
	}

	/**
	 * @param push the push to set
	 */
	public void setPush(String push) {
		this.push = push;
	}
	@Column(name = "submit_time")
	public Timestamp getSubmit_time() {
		return submit_time;
	}

	public void setSubmit_time(Timestamp submit_time) {
		this.submit_time = submit_time;
	}
	@Column(name = "submit_user_id")
	public String getSubmit_user_id() {
		return submit_user_id;
	}

	public void setSubmit_user_id(String submit_user_id) {
		this.submit_user_id = submit_user_id;
	}
    @Transient
	public String getSubmit_user_name() {
		return submit_user_name;
	}

	public void setSubmit_user_name(String submit_user_name) {
		this.submit_user_name = submit_user_name;
	}
	@Column(name = "pushInfo")
	public String getPushInfo() {
		return pushInfo;
	}

	public void setPushInfo(String pushInfo) {
		this.pushInfo = pushInfo;
	}
	@Transient
	public String getVideoFlag() {
		return videoFlag;
	}

	public void setVideoFlag(String videoFlag) {
		this.videoFlag = videoFlag;
	}
	@Transient
	public String getHaveNowTagFlag() {
		return haveNowTagFlag;
	}
	public void setHaveNowTagFlag(String haveNowTagFlag) {
		this.haveNowTagFlag = haveNowTagFlag;
	}
}